//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "common\fn_actionGet.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_item","_actions","_id","_result","_x"];
DEFAULT_PARAM(_item,0,[]);
DEFAULT_PARAM(_id,1,-1);
_actions = [];
if (typename _item == typename []) then {
	_actions = _item;
} else {
	_actions = [_item] call FFUNC(GetActions);
};
_result = (call CFUNC(hashEmpty));
if (count _actions > 0 && _id >= 0) then {
	if (typename _id == typename 0) then {
		{
			if (_id == ([_x, "__ACTION_ID__",-1] call CFUNC(HashGet))) exitWith {_result = _x};
		} foreach _actions;
	};
	if (typename _id == typename "") then {
		{
			if (_id == ([_x, "__ACTION_TYPE__",""] call CFUNC(HashGet))) exitWith {_result = _x};
		} foreach _actions;
	};
};
TRACE_1("End",_result);
TMFPROFILERSTOP;
_result;